<template>
  <div class="container">
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item
        v-for="item in recommendInfo.focusList"
        :key="item.id"
        height="3.7rem"
      >
        <img :src="item.picUrl" />
      </van-swipe-item>
    </van-swipe>
    <!-- 政策信息 -->
    <div class="policyDescList">
      <div
        class="policyDescItem"
        v-for="(item1, index) in recommendInfo.policyDescList"
        :key="index"
      >
        <img :src="item1.icon" alt="" />
        <span>{{ item1.desc }}</span>
      </div>
    </div>
    <!-- 导航格子 -->
    <div class="kingKongModule">
      <div
        class="kingKongItem"
        v-for="(item2, index) in recommendInfo.kingKongModule.kingKongList"
        :key="index"
      >
        <img :src="item2.picUrl" alt="" />
        <span>{{ item2.text }}</span>
      </div>
    </div>
    <div class="item">
      <!-- 促销广告 -->
      <div class="ads">
        <img
          src="https://yanxuan.nosdn.127.net/static-union/16560657356721aa.gif?imageView&quality=75"
          alt=""
        />
      </div>
      <!-- 新人专享礼 -->
      <div class="xinren">
        <div class="title"><h3>-新人专享礼-</h3></div>
        <div class="content">
          <div class="left">
            <span>新人专享礼包</span>
            <div class="imgWrap">
              <img
                src="https://yanxuan.nosdn.127.net/static-union/1648017994dd2933.png"
                alt=""
              />
            </div>
          </div>
          <div class="right">
            <div
              class="right1"
              v-for="(item3, index) in recommendInfo.indexActivityModule"
              :key="index"
            >
              <div class="title">{{ item3.title }}</div>
              <div class="subTitle">{{ item3.subTitle }}</div>
              <img :src="item3.picUrl" alt="" />
            </div>
            <!-- <div class="right2">
              <div class="title">福利社</div>
              <div class="subTitle">今日特价</div>
              <img src="../../static/images/lyml.jpg" alt="" />
            </div> -->
          </div>
        </div>
      </div>
      <!-- 类目热销榜 -->
      <div class="categoryHotSellModule">
        <p>{{ recommendInfo.categoryHotSellModule.title }}</p>
        <div class="categoryList">
          <van-grid
            column-num="2"
            class="categoryTopItem"
            gutter="4px"
            direction="horizontal"
          >
            <van-grid-item
              v-for="(
                item, index
              ) in recommendInfo.categoryHotSellModule.categoryList.slice(0, 2)"
              :key="index"
            >
              <span>{{ item.categoryName }}</span>
              <img :src="item.picUrl" alt="" />
            </van-grid-item>
          </van-grid>
          <van-grid class="categoryBottomItem" column-num="4" gutter="4px">
            <van-grid-item
              v-for="(
                item1, index
              ) in recommendInfo.categoryHotSellModule.categoryList.slice(2, 9)"
              :key="index"
            >
              <span>{{ item1.categoryName }}</span>
              <img :src="item1.picUrl" alt="" />
            </van-grid-item>
          </van-grid>
        </div>
      </div>
      <!--产品展示————明星爆款  -->
      <div class="itemPicBean">
        <van-grid class="itemPicBeanList" column-num="2" gutter="4px">
          <van-grid-item
            v-for="(item, index) in recommendInfo.sceneLightShoppingGuideModule"
            :key="index"
          >
            <span>{{ item.styleItem.title }}</span>
            <p>{{ item.styleItem.desc }}</p>
            <div>
              <img :src="item.styleItem.picUrlList[0]" alt="" />
              <img :src="item.styleItem.picUrlList[1]" alt="" />
            </div>
          </van-grid-item>
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "recommendInfo",
  mounted() {
    this.$store.dispatch("getRecommendInfo");
  },
  computed: {
    ...mapState({
      recommendInfo: (state) => state.home.recommendInfo,
      arr: (state) => state.home.arr,
    }),
  },
};
</script>

<style lang="less" scoped>
// 轮播图样式
.my-swipe .van-swipe-item {
  height: 200px;
  width: 100%;
  img {
    height: 100%;
    width: 100%;
  }
}
// 政策信息样式
.policyDescList {
  display: flex;

  .policyDescItem {
    flex: 1;
    text-align: center;
    img {
      width: 12px;
      height: 12px;
      vertical-align: middle;
      margin-right: 5px;
    }
    span {
      font-size: 12px;
      vertical-align: middle;
    }
  }
}
.kingKongModule {
  display: flex;
  flex-wrap: wrap;
  margin: 10px 0;
}
.kingKongItem {
  display: flex;
  flex-direction: column;
  width: 20%;
  align-items: center;
  img {
    width: 55px;
    height: 55px;
  }
  span {
    font-size: 13px;
    line-height: 30rpx;
    text-align: center;
  }
}
// 促销广告
.ads {
  // height: 0.4rem;
  img {
    width: 100%;
  }
}
//新人专享礼
.xinren {
  // display: block;
  // height: 240px;
  margin-top: 10px;
  box-sizing: border-box;
  h3 {
    font-size: 17px;
    text-align: center;
  }
  .content {
    margin-top: 10px;
    display: flex;
    width: 100%;
    height: 240px;
    // background-color: #666;
    .left {
      // width: 50%;
      flex: 1;
      height: 100%;
      background-color: #f9e9cf;
      margin-right: 5px;
      position: relative;
      span {
        font-size: 15px;
        padding: 20px;
        display: block;
      }
      img {
        width: 120px;
        height: 130px;
        position: absolute;
        top: 50%;
        left: 50%;
        margin-top: -50px; /* 高度的一半*/
        margin-left: -50px; /* 宽度的一半*/
      }
    }
    .right {
      flex: 1;
      // width: 50%;
      height: 100%;
      .right1 {
        height: 118px;
        background-color: #fbe2d3;
        position: relative;
        .subTitle {
          font-size: 15px;
          padding: 5px;
        }
        .title {
          font-size: 15px;
          padding: 5px;
        }
        img {
          width: 70px;
          height: 70px;
          position: absolute;
          top: 25px;
          left: 80px;
        }
      }
      .right2 {
        height: 118px;
        background-color: skyblue;
        margin-top: 4px;
        height: 118px;
        background-color: #ffecc2;
        position: relative;
        .subTitle {
          font-size: 15px;
          padding: 5px;
        }
        .title {
          font-size: 15px;
          padding: 5px;
        }
        img {
          width: 70px;
          height: 70px;
          position: absolute;
          top: 25px;
          left: 80px;
        }
      }
    }
  }
  //
}
//类目热销榜
.categoryHotSellModule {
  height: 410px;
  // margin: 15px;
  background-color: #eee;
  p {
    font-size: 20px;
    color: rgb(77, 75, 75);
    padding: 15px 4px;
  }
  .categoryTopItem {
    margin-bottom: 15px;
    height: 100px;
    img {
      width: 80px;
      height: 80px;
    }
    span {
      font-size: 14px;
    }
  }
  .categoryBottomItem {
    height: 100px;
    img {
      width: 60px;
      height: 60px;
    }
    span {
      font-size: 12px;
    }
  }
}
//产品展示————明星爆款
.itemPicBean {
  height: 155px;
  width: 100%;
  .itemPicBeanList {
    height: 155px;
    span {
      font-size: 18px;
    }
    p {
      font-size: 14px;
      color: red;
    }
    img {
      width: 75px;
      height: 75px;
    }
  }
}
</style>
